﻿using ComUIControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace USBControlDemo
{
    internal static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] arg)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool isRuned;
            System.Threading.Mutex mutex = new System.Threading.Mutex(true, "USBControlDemo", out isRuned);
            if (!isRuned)
            {
                MsgBox.Show("通断板控制程序已打开，不能重复启动。");
                return;
            }
            if (arg.Length == 2)
            {
                if (!string.IsNullOrEmpty(arg[1]))
                {
                    IntPtr WindowHandle = (IntPtr)Int32.Parse(arg[1]);
                    Application.Run(new Form1(WindowHandle));
                }
                else
                {
                    MsgBox.Show("参数无效，应用程序无法启动!");
                }
            }
            else
            {
                Application.Run(new Form1());
            }
        }
    }
}
